package com.koron.common.web.controller.message;

import com.github.pagehelper.PageInfo;
import com.koron.bean.base.Response;
import com.koron.bean.query.PageQuery;
import com.koron.common.core.business.message.bean.dto.MessageTopicDto;
import com.koron.common.core.business.message.bean.po.MessageTopicPo;
import com.koron.common.core.business.message.bean.vo.MessageTopicVo;
import com.koron.common.core.business.message.service.MessageTopicService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 消息主题表(MessageTopic)表控制层
 *
 * @author zhouj
 * @since 2022-03-16 14:14:09
 */
@Api(tags = "消息主题表(MessageTopic)")
@RestController
@RequestMapping("/messageTopic/")
public class MessageTopicController {

    @Autowired
    private MessageTopicService messageTopicService;

    @ApiOperation(value = "新增或修改消息主题表")
    @PostMapping("insertOrUpdate")
    public Response<MessageTopicPo> insertOrUpdate(@RequestBody MessageTopicDto messageTopicDto) {
        return Response.ok(ADOConnection.runTask(messageTopicService, "insertOrUpdate", MessageTopicPo.class, messageTopicDto));
    }

    @ApiOperation(value = "新增消息主题表")
    @PostMapping("insert")
    public Response<Integer> insert(@RequestBody MessageTopicPo messageTopic) {
        return Response.ok(ADOConnection.runTask(messageTopicService, "insert", Integer.class, messageTopic));
    }

    @ApiOperation(value = "批量新增消息主题表")
    @PostMapping("insertBatch")
    public Response<Integer> insertBatch(@RequestBody List<MessageTopicPo> messageTopicList) {
        return Response.ok(ADOConnection.runTask(messageTopicService, "insertBatch", Integer.class, messageTopicList));
    }

    @ApiOperation(value = "根据id更新消息主题表")
    @PutMapping("update")
    public Response<Integer> update(@RequestBody MessageTopicPo messageTopic) {
        return Response.ok(ADOConnection.runTask(messageTopicService, "update", Integer.class, messageTopic));
    }

    @ApiOperation(value = "根据id删除消息主题表")
    @DeleteMapping("deleteById")
    public Response<Integer> deleteById(String id) {
        return Response.ok(ADOConnection.runTask(messageTopicService, "deleteById", Integer.class, id));
    }

    @ApiOperation(value = "根据id查询消息主题表")
    @GetMapping("queryById")
    public Response<MessageTopicVo> queryById(String id) {
        return Response.ok(ADOConnection.runTask(messageTopicService, "queryById", MessageTopicVo.class, id));
    }

    @ApiOperation(value = "不分页查询消息主题表列表")
    @GetMapping("queryList")
    public Response<List<MessageTopicPo>> queryList(MessageTopicPo queryVo) {
        return Response.ok(ADOConnection.runTask(messageTopicService, "queryList", List.class, queryVo));
    }

    @ApiOperation(value = "分页查询消息主题表列表")
    @GetMapping("queryPageList")
    public Response<PageInfo> queryPageList(MessageTopicPo queryPo, PageQuery pageQuery) {
        return Response.ok(ADOConnection.runTask(messageTopicService, "queryPageList", PageInfo.class, queryPo, pageQuery));
    }

    @ApiOperation(value = "根据id查询消息主题表")
    @GetMapping("queryByCode")
    public Response<MessageTopicDto> queryByCode(String code) {
        return Response.ok(ADOConnection.runTask(messageTopicService, "queryByCode", MessageTopicDto.class, code));
    }

}
